// import { OpenURLByAppFormate } from 'vue-xiaobu-utils'
function open(url) {
  if (window.prodInApp) {
    // OpenURLByAppFormate(url)
    if (url.indexOf('http') === 0 || url.indexOf('xbapp') === 0) {
      window.location.assign(url)
    } else {
      if (url.indexOf('-app') > -1) {
        window.location.assign('xbapp://open/' + url)
      } else {
        window.location.assign('xbapp://open/' + window.folderName + url)
      }
    }
  } else {
    window.location.assign(url)
    // alert('跳转地址：' + url)
  }
}

function back(url = '') {
  if (window.prodInApp) {
    // OpenURLByAppFormate(url)
    let backUrl = 'xbapp://goback'
    if (url) {
      backUrl += '/' + window.folderName + url
    }
    window.location.assign(backUrl)
  } else {
    // window.location.assign(url)
    alert('返回地址：' + url)
  }
}

function goToOrderDetail(orderId) {
  open('shop-app/orderdetail.html?orderType=1&stype=6&orderId=' + orderId)
}

export { open, back, goToOrderDetail }
